add_custom_target(target ALL)
set_target_properties(target PROPERTIES COMPILE_DEFINITIONS "touched" COMPILE_OPTIONS "${CMAKE_BINARY_DIR}/wdir")
file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/wdir")

add_custom_command(
  TARGET target
  POST_BUILD
  COMMAND ${CMAKE_COMMAND} -E touch $<TARGET_PROPERTY:COMPILE_DEFINITIONS>
  WORKING_DIRECTORY $<TARGET_PROPERTY:COMPILE_OPTIONS>
)
